package dk.au.cs.peterbn.patterns.impl;

import dk.au.cs.peterbn.patterns.CallSite;
import dk.au.cs.peterbn.patterns.MemberRole;
import dk.au.cs.peterbn.patterns.TypeRole;

/**
 * Default implementation of callsite
 */
public class CallSiteImpl implements CallSite {
    private Restriction restriction;
    private String type;
    private final DesignPatternImpl pattern;
    private String member;

    public CallSiteImpl(DesignPatternImpl pattern) {
        this.pattern = pattern;
    }

    @Override
    public Restriction getRestriction() {
        return restriction;
    }

    @Override
    public TypeRole getType() {
        return pattern.getTypeRole(type);
    }

    @Override
    public MemberRole getMember() {
        if (member != null) {
            return pattern.getMember(member);
        } else {
            return null;
        }
    }

    public void setRestriction(Restriction restriction) {
        this.restriction = restriction;
    }

    public void setType(String type) {
        this.type = type;
    }

    public void setMember(String member) {
        this.member = member;
    }
}
